<?php
/**
 * 操作返回信息类
 *
 * @author: WangBin
 * @date: 2021/7/16
 * @mail: <849850352@qq.com>
 */
namespace App\Entity;
class OpResult
{
    // 标识 0失败1成功
    private $code = 0;
    // 提示语
    private $message = '操作失败';
    // 需返回的数据
    private $data = null;

    private static $instance = null;

    /**
     * @return OpResult|static
     */
    public static function create()
    {
        return self::$instance ?? new static();
    }

    /**
     * @return int
     */
    public function getCode(): int
    {
        return $this->code;
    }

    /**
     * @param int $code
     * @return static
     */
    public function setCode(int $code)
    {
        $this->code = $code;
        return $this;
    }

    /**
     * @return string
     */
    public function getMessage(): string
    {
        return $this->message;
    }

    /**
     * @param string $message
     * @return static
     */
    public function setMessage(string $message)
    {
        $this->message = $message;
        return $this;
    }

    /**
     * @return null
     */
    public function getData()
    {
        return $this->data;
    }

    /**
     * @param null $data
     * @return static
     */
    public function setData($data)
    {
        $this->data = $data;
        return $this;
    }
}